package com.xhwy.util;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {

    /**
     * 根据年份获取第一天的时间戳
     * @return
     */
    public static Date getFirstDayOfYear(int year){
        //jdk1.8
        //获取今年的年份
//        LocalDate today = LocalDate.now();
//        int year = today.getYear();
//        System.out.println(year);
//        LocalDate firstDayOfYear = today.with(TemporalAdjusters.firstDayOfYear());

        Calendar calendar = Calendar.getInstance();
        //重置时间到1970-1-1
        calendar.clear();
        //设置年份
        calendar.set(Calendar.YEAR,year);
//        calendar.set(2022,0,0);
        Date time = calendar.getTime();
        return time;

    }
}
